/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
    var path_name = window.location.href.toString().split("/")[3]; //orderservice
    var base_url = window.location.origin; //http://localhost
    var full_path_name = base_url+"/"+path_name; //http://localhost/orderservice
$(document).ready(function() {

//$(function(){
    getDistrictIndex();
    getImgDefault();
    
});
function getDistrictIndex() {
    
    $("#SalePointForm_area").change(function(n){
        var t,i;
        n.preventDefault();
        t=$("#SalePointForm_area option:selected").val();
        t!="0"&&(i={city:t}, $.getJSON(full_path_name+"/index.php/site/GetlstDistricts", i, function(n){
            var options = '';
            for (var i = 0; i < n.length; i++) {
                options += '<option value="' + n[i] + '">' + n[i] + '</option>';
            };
            $("select#SalePointForm_district").html("<option value='0'>Chọn Quận<\/option>"+options);
        }));
    });
}
/*function getDistrictAdmin() {
    if($('#SalePointModel_area').length <= 0 )
        return false;
    $("select#SalePointModel_area").change(function(m){
        var y,j;
       m.preventDefault();
        y=$("select#SalePointModel_area option:selected").val();
        y!="0"&&(j={city:y}, $.getJSON("../site/GetlstDistricts", j, function(m){
            var options = '';
            for (var i = 0; i < m.length; i++) {
                options += '<option value="' + m[i] + '">' + m[i] + '</option>';
            };
            $("select#SalePointModel_district").html("<option value='0'>Chọn Quận<\/option>"+options);
        }));
    });
}*/
function getImgDefault() {
        $("img").error(function () {
        $(this).unbind("error").attr("src",full_path_name+"/images/photo.png");
    });
}
/*
function getDistrictSearch() {
    if($('#city').length <= 0 )
        return false;
    $("select#city").change(function(m){
        var y,j;
       m.preventDefault();
        y=$("select#city option:selected").val();
        y!="0"&&(j={city:y}, $.getJSON(full_path_name+"/index.php/site/GetlstDistricts", j, function(m){
            var options = '';
            for (var i = 0; i < m.length; i++) {
                options += '<option value="' + m[i] + '">' + m[i] + '</option>';
            };
            $("select#district").html("<option value='0'>Chọn Quận<\/option>"+options);
        }));
    });
}*/


